from fastapi import FastAPI, Depends
from typing import Optional
from pydantic import BaseModel
import uvicorn

app = FastAPI()

class UserModel(BaseModel):
    username:str
    decription:Optional[str] = "default"


def page_info(page_index:Optional[int] = 1, page_size:Optional[int]=10):

    return {"page_index":page_index, "page_size":page_size}


class ResponseModel(BaseModel):
    page_index:int
    page_size:int



@app.get("/items", response_model=ResponseModel)
async def get_items(page_info:dict=Depends(page_info)):
    return page_info



@app.post("/users")
async def get_items(page_info:UserModel):
    return page_info


if __name__ == "__main__":
    uvicorn.run("run:app", reload=True)